<!DOCTYPE html>

<html class="no-js">

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title></title>
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>
  <script src="../../cdn/vue/vue.global.min.js"></script>
  <link rel="stylesheet" href="../../cdn/element-plus/index.css" />
  <script src="../../cdn/element-plus/index.full.min.js"></script>

  <link rel="stylesheet" href="../../../lib/index.css" />
  <script src="../../../lib/avue.js"></script>
</head>

<body>
  <div id="app">
    {{obj}}
    <avue-form :option="option" v-model="obj" @submit="submit"></avue-form>
  </div>
</body>
<script>
  let baseUrl = 'https://cli.avuejs.com/api/area'
  var app = Vue.createApp({
    data() {
      return {
        obj: {},
        option: {
          card: false,
          labelWidth: 110,
          column: [
            {
              label: '省份',
              prop: 'province',
              type: 'select',
              props: {
                label: 'name',
                value: 'code'
              },
              cascader: ['city'],
              dicUrl: `${baseUrl}/getProvince`,
              rules: [
                {
                  required: true,
                  message: '请选择省份',
                  trigger: 'blur'
                }
              ]
            }, {
              label: '测试',
              prop: 'text'
            },
            {
              label: '城市',
              prop: 'city',
              type: 'select',
              cascader: ['area'],
              cascaderIndex: 1,
              props: {
                label: 'name',
                value: 'code'
              },
              dicUrl: `${baseUrl}/getCity/{{key}}`,
              rules: [
                {
                  required: true,
                  message: '请选择城市',
                  trigger: 'blur'
                }
              ]
            }, {
              label: '测试',
              prop: 'text1'
            },
            {
              label: '地区',
              prop: 'area',
              multiple: true,
              all: true,
              type: 'select',
              props: {
                label: 'name',
                value: 'code'
              },
              cascaderIndex: 1,
              dicUrl: `${baseUrl}/getArea/{{key}}`,
              rules: [
                {
                  required: true,
                  message: '请选择地区',
                  trigger: 'blur'
                }
              ]
            }]
        }
      }
    },
    watch: {
      'obj.selects'() {
        console.log(1);
      }
    },
    mounted() {
      this.obj = {
        switch: '1',
        selects: '0,1',
        name: 'small',
        cascader: [0, 1],
        number: 1,
        tree: [2],
        checkbox: ['110000'],
        province: '220000',
        city: '220700',
        area: '220701',
        icon: 'el-icon-error',
      }
    },
    methods: {
      submit(form, done) {
        this.$message.success('3s后关闭');
        setTimeout(() => {
          done()
        }, 3000)
      }
    }
  })
  app.use(ElementPlus)
  app.use(AVUE)
  app.mount('#app')
</script>

</html>